package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.UserModel
import com.powervision.mvvmdemo.ui.repository.RegisterRepository

/**
 * @auth: njb
 * @date: 2021/12/13 15:25
 * @desc: 描述
 */
class RegisterViewModel : BaseViewModel() {
    private val registerRetention by lazy { RegisterRepository() }

    val userLiveData = StateLiveData<UserModel?>()

    fun register(username: String, password: String, repassword: String) {
        launchWithLoading(requestBlock = {
            registerRetention.register(
                username,
                password,
                repassword
            )
        },
            resultCallback = {
                userLiveData.value = it
            }
        )
    }
}